#ifndef __MCS__PARSER_DEFINES__HPP
#define __MCS__PARSER_DEFINES__HPP

#include "Object.hpp"
#include "SourceLocation.hpp"
#include <iostream>

typedef ptr<Object> ObjectPtr;
#define YYSTYPE ObjectPtr

//avoid including location.hh
#define BISON_LOCATION_HH

namespace yy
{
	class location : public SourceLocation
	{
	public:
		location() {}
		location(SourceLocation const & other) : SourceLocation(other) {}
		location(String const & file) : SourceLocation(file) {}
		location(String const & file, int line) : SourceLocation(file, line) {}
		location(String const & file, int line, int col) : SourceLocation(file, line, col) {}
		location(String const & file, int line1, int col1, int line2, int col2) : SourceLocation(file, line1, col1, line2, col2) {}
		location(SourcePosition const & p) : SourceLocation(p) {}
		location(SourcePosition const & b, SourcePosition const & e) : SourceLocation(b, e) {}
		
		location & operator=(location const & other)
		{
			SourceLocation::operator=(other);
			return *this;
		}
	};
}

#ifndef YYLLOC_DEFAULT
# define YYLLOC_DEFAULT(Current, Rhs, N)             \
	do {                                             \
		if (N)                                       \
		{                                            \
			(Current).setBegin((Rhs)[1].begin());    \
			(Current).setEnd((Rhs)[N].end());        \
		}                                            \
		else                                         \
		{                                            \
			(Current).setBegin((Rhs)[0].end());      \
			(Current).setEnd((Rhs)[0].end());        \
		}                                            \
	} while (false)
#endif //YYLLOC_DEFAULT

class Lexer;

#include "parser.hpp"

#endif //__MCS__PARSER_DEFINES__HPP